package com.catarc.unityback.controller;

import com.catarc.unityback.entity.dto.GameObjectMoveDTO;
import com.catarc.unityback.entity.vo.MyPerson;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.iohao.game.bolt.broker.client.kit.ExternalCommunicationKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * @author van
 * @date 2023/2/1 20:25
 */
@Slf4j
@RestController
public class TestController {

    public static List<GameObjectMoveDTO> moveDTOList = Lists.newArrayList();
    public static Set<String> activeModelNames = Sets.newHashSet();

    @GetMapping("/test/get/str")
    public String getStrTest() {
        return "获取字符串";
    }

    @GetMapping("/test/get/int")
    public Integer getIntTest(){
        return 999;
    }

    @GetMapping("/test/get/person")
    public MyPerson getPersonTest(@RequestParam("id") Long id) {
        return MyPerson.builder()
                .id(id).name("测试人员").isMan(id > 5).build();
    }

    @PostMapping("/test/move/put")
    public void putMoveData(@RequestBody List<GameObjectMoveDTO> dto) {
        moveDTOList = dto;
    }

    @GetMapping("/test/move/get")
    public List<GameObjectMoveDTO> getMoveData() {
        return moveDTOList;
    }

    @GetMapping("/test/model/active/set")
    public void setModelActive(@RequestParam("name") String modelName) {
        activeModelNames.add(modelName);
    }

    @GetMapping("/test/model/active/clear")
    public void clearModelActive(@RequestParam("name") String name) {
        activeModelNames.remove(name);
    }

    @GetMapping("/test/model/active/get")
    public Set<String> getModelActive() {
        return activeModelNames;
    }

    @GetMapping("/test/user/get/id/{id}")
    public void getUser(@PathVariable Long id) {
        log.error("测试存在玩家");
        boolean b = ExternalCommunicationKit.existUser(id);
        log.info(String.valueOf(b));
    }
}
